import { _decorator, Component, Node, SpriteComponent, Color } from 'cc';
import BaseView from '../game/BaseView';
import GDef from '../config/GDef';
import GD from '../config/GD';
const { ccclass, property } = _decorator;

@ccclass('bgColor')
export class bgColor extends BaseView {
    /* class member could be defined like this */
    // dummy = '';

    /* use `property` decorator if your want the member to be serializable */
    // @property
    // serializableDummy = 0;
    private bgColor = [[255,255,255],[253, 183, 51], [150, 109, 205], [88, 187, 246], [114, 199, 82], [206, 140, 202], [234, 136, 61], [234, 89, 70], [157, 221, 23], [235, 62, 126], [65, 231, 169]];
    public color = new Color();
    @property({
        type: SpriteComponent   
    })
    spCtr: SpriteComponent = null;
    init() {
        // const num = GD.getCheckpoint();
        const num = 0;
        const index = num % 10;
        
        this.color._set_r_unsafe(this.bgColor[index][0]);
        this.color._set_g_unsafe(this.bgColor[index][1]);
        this.color._set_b_unsafe(this.bgColor[index][2]);
        this.spCtr.color = this.color;
    }
    start() {
        this.on(GDef.wdEvent.next,this.init);
        this.init();
        // Your initialization goes here.
    }

    // update (deltaTime: number) {
    //     // Your update function goes here.
    // }
}
